package cn.edu.ctbu.scoremg.api;

import cn.edu.ctbu.scoremg.interceptor.LoginInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

public class WebConfig implements WebMvcConfigurer {

    public void addInterceptor(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/**")  //拦截所有请求
                .excludePathPatterns("/login","/api/student/validateUser","/api/admin/validateUser","/api/teacher/validateUser",
                        "/css/**","/admin/**","/view/**");  //触发登录页面和静态资源
    }
}
